package net.lzzy.practices.web.models;

import lombok.Getter;
import lombok.Setter;
import net.lzzy.practices.entities.Chapter;

import java.util.Date;
import java.util.UUID;


@Setter
@Getter
public class VmChapter {
    private   UUID id;
    private  String name;
    private  String desc;
    private  Date updateDate;
    private  Date createDate;
    private   boolean open;
    private  UUID teacherId;
    private  String teacherName;
    private  String teacherAvatar;
    private int countChapter;
    private int countStudents;
    private VmChapter(){};

    public static  VmChapter create(Chapter chapter){
        VmChapter vmChapter = new VmChapter();
        vmChapter.setId(chapter.getId());
        vmChapter.setName(chapter.getName());
        vmChapter.setDesc(chapter.getDescription());
        vmChapter.setOpen(chapter.isOpen());
        vmChapter.setCreateDate(chapter.getCreateTime());
        vmChapter.setUpdateDate(chapter.getUpdateTime());
        vmChapter.setTeacherName(chapter.getCourse().getTeacher().getNickName());
        vmChapter.setTeacherAvatar(chapter.getCourse().getTeacher().getAvatar());
        vmChapter.setCountStudents(chapter.getCourse().getStudents().size());
        vmChapter.setTeacherId(chapter.getCourse().getTeacher().getId());
        return vmChapter;
    }
}
